<html>
<head><meta charset="utf-8"><title>cfg declarations and implicit returns · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/cfg.20declarations.20and.20implicit.20returns.html">cfg declarations and implicit returns</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="233468705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/cfg%20declarations%20and%20implicit%20returns/near/233468705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/cfg.20declarations.20and.20implicit.20returns.html#233468705">(Apr 07 2021 at 11:07)</a>:</h4>
<p>I've been looking into solving <a href="https://github.com/rust-analyzer/rust-analyzer/issues/8378">rust-analyzer#8378</a>. </p>
<p>I think the solution would look like modifying <a href="https://github.com/rust-analyzer/rust-analyzer/blob/a8f1e41f0f15fee02a73850db559752a9124d014/crates/hir_def/src/body/lower.rs#L697">https://github.com/rust-analyzer/rust-analyzer/blob/a8f1e41f0f15fee02a73850db559752a9124d014/crates/hir_def/src/body/lower.rs#L697</a> to fallback to the last not cfged out statement, if and only if that statement is an expression statement without a semicolon. However, I can't inerate backwards through AstChildren, because that is not implemented (in rowan), although the impl should be cheap. I could just allocate a temporary vector, but I don't feel like that's the best solution.</p>



<a name="233472776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/cfg%20declarations%20and%20implicit%20returns/near/233472776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Mcnab <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/cfg.20declarations.20and.20implicit.20returns.html#233472776">(Apr 07 2021 at 11:47)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/pull/8398">https://github.com/rust-analyzer/rust-analyzer/pull/8398</a></p>
<p>Wasn't too bad, if people think this design makes sense.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>